<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
       <label for="">用户名</label>
        <input type="text">
       <button>点击</button>
</body>
</html>

<script>

document.getElementsByTagName('button')[0].onclick=()=>{
  
    let inputObj = document.getElementsByTagName('input')[0];

    //console.log(inputObj.value);

    inputObj.value='萨达水';

}


</script>